<%@page import="com.meila.cms.entity.User"%>
<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.meila.cms.util.config.Property"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="el"  uri="toJson.com/el-common" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"  %> 
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%
 
 String path = request.getContextPath();
 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 User user=((User) session.getAttribute("loginUser"));
%>
<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
 
<!--     <meta http-equiv="pragma" content="no-cache"> 
	<meta http-equiv="cache-control" content="no-cache, must-revalidate"> 
	<meta http-equiv="expires" content="0"> -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>整车平台</title>
    
    <base href="<%=basePath%>">
	<link href="resources/css/system/carDesign/design.css" rel="stylesheet"></link>

 
	<!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
  </head>

  <body class="client-body" id="loading">
  
  		<jsp:include page="../common/design-head.jsp"></jsp:include>
 
	  	<script src="resources/js/system/carDesign/designCommon.js"></script>
	  	<script src="resources/js/system/carDesign/designCar.js"></script>
  		<!-- 左 -->
  		<div class="design-body design-bodyLeft">
			<div class="design-leftTag">车型号选择</div>
			<div class="design-leftmenu fontBox clearfix">
			     <c:forEach var="dict" items="${dictList}">
				    <a class="a-black ${carDesignModel.cartype==dict.value? 'activeFont':''}" href="javascript:getCarList(${dict.value})">${dict.name}</a>
				 </c:forEach>
			</div>
			
			<div class="left-oneImgList listImgBox">
			  <c:forEach var="car" items="${carList}">
					<div class="left-oneImgBlock leftImgBlock ${car.id==carDesignModel.carid? 'activeImg':''}">
						<div class="left-oneImgBox"><img src="<%=Property.getProperty("FILESERVER_PATH") %>?id=${car.carsidepic}"/></div>
						<div class="left-oneImgName">${car.name}</div>
					    <input type="hidden" value="${el:toJsonString(car)}">
					</div>
               </c:forEach>
			</div>
		</div>
  		
  		<!-- 中 -->
  		<div class="design-body design-bodyMiddle">
  			<div class="design-btnBox btnBox clearfix"  style="display: none">
				<a class="a-black activeBtn" href="javascript:;">匹配零件</a>
			</div>
			
  			<div class="design-btnBox btnBox clearfix" style="display: ${carDesignModel.carid!=null? '':'none'}">
				<a class="a-black activeBtn" href="javascript:;">2D</a>
				<a class="a-black" href="front/carDesign/partList?designid=${param.id}">零件清单</a>
				<a class="a-black" href="front/carDesign/craftOrder?designid=${param.id}">工艺指令</a>
				<a class="a-black" href="javascript:;" style="display: none">装配调试</a>
			</div>
			
			<div class="design-middleActions">
				<a class="a-white activeBtn" href="front/carDesign/carDesign_list"><i class="fa fa-arrow-right"></i></a>
				<a class="a-white" href="front/carDesign/exportPDF?designid=${param.id}&type=3"><i class="fa fa-download"></i></a>
				<a class="a-white" href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
			</div>
			
			<div class="middle-towImgList clearfix">
				<a class="middle-twoImgBox middle-imgFirst" id="carsidepic_a"><img id="carsidepic_img"/></a>
				<a class="middle-twoImgBox" id="carfrontpic_a"><img id="carfrontpic_img"></a>
				<a class="middle-twoImgBox" id="carafterpi_a"><img id="carafterpic_img"/></a>
			</div>
  		</div>
  		
  		<!-- 右 -->
  		<div class="design-body design-bodyRight">
			<div class="design-leftTag">细节设置</div>
			
			<div class="design-rightForm">
				<form class="form-horizontal" id="carDesignform">
				   <div class="rightFormUp"> 
					  <div class="form-group">
   
					    <label class="col-sm-4 control-label">设计名</label>
					    <div class="col-sm-8">
					          <input id="type" name="type"  class="form-control"  type="hidden" value="1">
						      <input id="carid" name="carid"  class="form-control"  type="hidden" value="${carDesignModel.carid}">
						      <input id="name" name="name"  class="form-control"  type="hidden" value="${carDesignModel.name}">
						      <input id="comment" name="comment"  class="form-control"  type="hidden" value="${carDesignModel.comment}">
						      <input id="cartype" name="cartype"  class="form-control"  type="hidden" value="${carDesignModel.cartype}">
						      <input id="id" name="id" type="hidden" class="form-control"  value="${carDesignModel.id}">
					          <input id="designname" name="designname" class="form-control" type="text" style="width: 100%" value="${carDesignModel.designname}">
					    </div>
					  </div>
					  
					  <div class="form-group">
					    <label class="col-sm-4 control-label">型号</label>
					    <div class="col-sm-8">
					      <div class="rightForm-carType" id="carType">${carDesignModel.cartypeName}</div>
					    </div>
					  </div>
					  
					  <div class="form-group">
					    <label class="col-sm-4 control-label">车身颜色</label>
					    <div class="col-sm-8">
					        <c:forEach var="carColor" items="${carColorList}" varStatus="vs">
							    <div class="rightForm-carColor  ${carColor.value==carDesignModel.carcorlor? 'nowColor':''}">
							        <span class="carColor${vs.count}"></span>
							        <i class="fa fa-check-circle"></i>
							        <input type="hidden" value="${carColor.value}">
							     </div>
                            </c:forEach>
                            <input type="hidden" name="carcorlor"  id="carcorlor"  class="form-control" value="${carDesignModel.carcorlor}">
					    </div>
					  </div>
				     
					  <div class="form-group">
					    <label class="col-sm-4 control-label">车牌</label>
					    <div class="col-sm-8">
					       <select class="form-control" id="licence" name="licence">
							</select>
					    </div>
					  </div>
				 	</div><!-- rightFormUp -->
				 	
				 	<div class="rightFormDown">
				 		<div class="form-group">
						    <label class="col-sm-4 control-label">长</label>
						    <div class="col-sm-8">
						      <input type="text"   class="form-control" name="length_deci"  id="length_deci"  value="${carDesignModel.length/100}" onchange="$('#length').val(this.value*100)" onKeyUp="amount(this)"  /> 米
						      <input type="hidden" class="form-control" name="length"  id="length"  value="${carDesignModel.length}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">宽</label>
						    <div class="col-sm-8">
						       <input type="text" class="form-control"  name="width_deci"  id="width_deci"  value="${carDesignModel.width/100}" onchange="$('#width').val(this.value*100)" onKeyUp="amount(this)"  /> 米
						       <input type="hidden" class="form-control"  name="width"  id="width"  value="${carDesignModel.width}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">高</label>
						    <div class="col-sm-8">
						        <input type="text" class="form-control"  name="heigh_deci"  id=heigh_deci value="${carDesignModel.heigh/100}"  onchange="$('#heigh').val(this.value*100)" onKeyUp="amount(this)" /> 米
						        <input type="hidden" class="form-control"  name="heigh"  id="heigh"  value="${carDesignModel.heigh}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">轴距</label>
						    <div class="col-sm-8">
						        <input type="text" class="form-control"  name="wheelbase_deci"  id="wheelbase_deci" value="${carDesignModel.wheelbase/100}"  onchange="$('#wheelbase').val(this.value*100)" onKeyUp="amount(this)" /> 米
						        <input type="hidden" class="form-control"  name="wheelbase"  id="wheelbase"  value="${carDesignModel.wheelbase}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">轮距</label>
						    <div class="col-sm-8">
						        <input type="text" class="form-control"  name="tread_deci"  id="tread_deci" value="${carDesignModel.tread/100}"  onchange="$('#tread').val(this.value*100)" onKeyUp="amount(this)" /> 米
						        <input type="hidden" class="form-control"  name="tread"  id="tread"  value="${carDesignModel.tread}"/>
						    </div>
						  </div>
						  
						  <div class="form-group">
						    <label class="col-sm-4 control-label">前后轮距</label>
						    <div class="col-sm-8">
						        <input type="text" class="form-control"  name="track_deci"  id="track_deci" value="${carDesignModel.track/100}"  onchange="$('#track').val(this.value*100)" onKeyUp="amount(this)" /> 米
						        <input type="hidden" class="form-control"  name="track"  id="track"  value="${carDesignModel.track}"/>
						    </div>
						  </div>
				 	</div><!-- rightFormDown -->
		 
			        <div class="form-group">
					    <div class="col-sm-12 rightForm-footBtn">
				            <a class="btn btn2 a-white" href="javascript:this.location.reload()">重置</a>
				            <a class="btn btn2 right a-white" href="javascript:submitCarDesignform('${carDesignModel.carid}','${param.designname==null? 1:2}')">保存修改</a>
					    </div>
				    </div>
				</form> 
			</div>
		</div>
  		
  		
  		
	  	<!-- Modal 保存修改-->
		<div class="modal fade" id="carModifyModal" tabindex="-1" role="dialog" aria-labelledby="carModifyModalLabel" data-backdrop="static">
		  <div class="modal-dialog modal-sm">
		    <form action="">
			    <div class="modal-content">
			      
			      <div class="modal-body">
					  <div class="carModal-body">
					    <i class="fa fa-check-circle"></i>
					    <span>您已保存成功！</span>
					  </div>
			      </div>
			      
			      <div class="modal-footer carModal-footer">
			        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			        <!-- <button type="submit" class="btn btn2 a-white">保存并退出</button> -->
			      </div>
			      
			    </div>
		     </form>
		  </div>
		</div>
 
	<script type="text/javascript">
	    var userid=<%=user==null? null:user.getId()%>;
	    
  	    if('${carDesignModel.carsidepic}'!=''){
  	      $("#carsidepic_img").attr('src',FILESERVER_PATH+"?id="+'${carDesignModel.carsidepic}&timestr='+new Date().getTime());
  	    }
  	    if('${carDesignModel.carsidepic}'!=''){
  	      $("#carfrontpic_img").attr('src',FILESERVER_PATH+"?id="+'${carDesignModel.carfrontpic}&timestr='+new Date().getTime());
  	    }
	    if('${carDesignModel.carsidepic}'!=''){
  	      $("#carafterpic_img").attr('src',FILESERVER_PATH+"?id="+'${carDesignModel.carafterpic}&timestr='+new Date().getTime());
  	    }

        //新建整车设计时不能修改logo
  	    if('${param.id}'!=''){
  	       $("#carsidepic_a").attr('href',"front/carDesign/carLogoModify?id="+'${param.id}'+"&logopart=1");
  	       $("#carfrontpic_a").attr('href',"front/carDesign/carLogoModify?id="+'${param.id}'+"&logopart=2");
  	       $("#carafterpi_a").attr('href',"front/carDesign/carLogoModify?id="+'${param.id}'+"&logopart=3");
  	       
 	    }
          
	  $.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'common/selectByComboCategory?category=LicensePlate',  
	        dataType : "json",  
	        cache : false,  
	        async : false,  
	        success : function(data) {  
 
	            var optionStr = '';  
	            for (var i = 0; i < data.length; i++) {  
                    if('${carDesignModel.licence}'==data[i].value){
                          optionStr += "<option selected value="+data[i].value+">"+data[i].text+"</option>";  
                    }else{
                          optionStr += "<option value="+data[i].value+">"+data[i].text+"</option>"; 
                    }
	                 
	            }  
	            $("#licence").html("<option value=''>全部</option>" + optionStr);  
	        }  
	    }); 
  	
  	</script>
    
  </body>
</html>


